package site.enjoyrun.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import site.enjoyrun.mapper.OrderMapper;
import site.enjoyrun.model.Order;
import site.enjoyrun.service.OrderService;
import java.util.List;

@Service("orderService")
public class OrderServiceImpl implements OrderService {

    @Autowired
    OrderMapper orderMapper;

    @Override
    public List<Order> getAllOrder(){
        List<Order> orders = null;
        try {
            orders = orderMapper.selectOrders();
        } catch (Exception e) {
            System.out.println(e);
        }

        return orders;
    }

    @Override
    public boolean insertOrder(Order order){
        boolean res = false;
        try {
            res = orderMapper.insertOrder(order) > 0;
        } catch (Exception e) {
            System.out.println(e);
        }
        return res;
    }

    @Override
    public boolean updateOrder(Order order) {
        boolean res = false;
        try {
            res = orderMapper.updateOrder(order) > 0;
        } catch (Exception e) {
            System.out.println(e);
        }

        return res;
    }

    @Override
    public boolean deleteOrder(String oId)
    {
        boolean res = false;
        try {
            res = orderMapper.deleteOrder(oId) > 0;
        } catch (Exception e) {
            System.out.println(e);
        }
        return res;
    }
}
